<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.60">
    <script>
      (function() {
        const userMode = localStorage.getItem('vuepress-reco-color-scheme') || 'auto';
        const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

        if (userMode === 'dark' || (userMode === 'auto' && systemDarkMode)) {
          document.documentElement.classList.toggle('dark', true);
        }
      })();
    </script>
    <link rel="icon" href="/logo.png"><title>objectivec基础用法 | 王茂铭</title><meta name="description" content="Just playing around">
    <link rel="modulepreload" href="/wb/assets/app-32a7af8e.js"><link rel="modulepreload" href="/wb/assets/framework-c27b6911.js"><link rel="modulepreload" href="/wb/assets/092106.html-6d252224.js"><link rel="modulepreload" href="/wb/assets/092106.html-709c9d31.js"><link rel="prefetch" href="/wb/assets/index.html-6d5e9dd3.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-8e728de0.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-71f98eb6.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-47172bd3.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c4d32c30.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-75e9cb1a.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-a2c706b5.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-17c6444b.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-6958f27b.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-d981608d.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-ff4c5386.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-97c1c024.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-8596a00c.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-2434c570.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-0b4e72f2.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-70379254.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-bcce1cd3.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-e1575d57.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c08582eb.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-4df8ef63.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-fa97dbe9.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-ea3cbcd8.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-5d7f901a.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-ec6cc437.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-8802c78f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c5b96a91.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-55c1ed81.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-f36d8351.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-da9b2394.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-5ac52d4f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-27e68ae7.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-1834aef1.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-d4810458.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-560c14b4.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-35b38f45.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-93b00c29.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-f42fa99c.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c7a62b28.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-7f3eeb92.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c8596e07.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-f6681850.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-2773f5fc.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-6cf06f14.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-1a88d37b.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c8e98ed0.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-800887e5.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-06f5ab5e.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-db4c3376.js" as="script"><link rel="prefetch" href="/wb/assets/031101.html-02798306.js" as="script"><link rel="prefetch" href="/wb/assets/031102.html-15b3adb4.js" as="script"><link rel="prefetch" href="/wb/assets/031501.html-3134e3b4.js" as="script"><link rel="prefetch" href="/wb/assets/122102.html-ceeb362a.js" as="script"><link rel="prefetch" href="/wb/assets/010601.html-3fe2b350.js" as="script"><link rel="prefetch" href="/wb/assets/010602.html-d33aafe0.js" as="script"><link rel="prefetch" href="/wb/assets/010603.html-731c8a98.js" as="script"><link rel="prefetch" href="/wb/assets/010604.html-6bc8d643.js" as="script"><link rel="prefetch" href="/wb/assets/010701.html-12966c2a.js" as="script"><link rel="prefetch" href="/wb/assets/010801.html-0fca227d.js" as="script"><link rel="prefetch" href="/wb/assets/011001.html-d10dc4a2.js" as="script"><link rel="prefetch" href="/wb/assets/011201.html-bbd7d0bc.js" as="script"><link rel="prefetch" href="/wb/assets/011202.html-f1b9f476.js" as="script"><link rel="prefetch" href="/wb/assets/011301.html-f7ba82d3.js" as="script"><link rel="prefetch" href="/wb/assets/011501.html-9196b987.js" as="script"><link rel="prefetch" href="/wb/assets/010501.html-43e0fee1.js" as="script"><link rel="prefetch" href="/wb/assets/031801.html-0a02ab60.js" as="script"><link rel="prefetch" href="/wb/assets/092102.html-74b61e87.js" as="script"><link rel="prefetch" href="/wb/assets/092103.html-2c9d1221.js" as="script"><link rel="prefetch" href="/wb/assets/081101.html-86de4307.js" as="script"><link rel="prefetch" href="/wb/assets/092001.html-20d934d3.js" as="script"><link rel="prefetch" href="/wb/assets/092101.html-1890511d.js" as="script"><link rel="prefetch" href="/wb/assets/092102.html-ae3f31b4.js" as="script"><link rel="prefetch" href="/wb/assets/092103.html-74cff86b.js" as="script"><link rel="prefetch" href="/wb/assets/092104.html-004f7a47.js" as="script"><link rel="prefetch" href="/wb/assets/092105.html-3f3fe144.js" as="script"><link rel="prefetch" href="/wb/assets/122101.html-f85b1d72.js" as="script"><link rel="prefetch" href="/wb/assets/122201.html-572b8a97.js" as="script"><link rel="prefetch" href="/wb/assets/092105.html-b6d3d031.js" as="script"><link rel="prefetch" href="/wb/assets/121501.html-6bc29a5d.js" as="script"><link rel="prefetch" href="/wb/assets/092101.html-f5635806.js" as="script"><link rel="prefetch" href="/wb/assets/092105.html-054223dd.js" as="script"><link rel="prefetch" href="/wb/assets/guide.html-561bbc0f.js" as="script"><link rel="prefetch" href="/wb/assets/011301.html-a89f05e1.js" as="script"><link rel="prefetch" href="/wb/assets/021401.html-b25135ac.js" as="script"><link rel="prefetch" href="/wb/assets/022001.html-3fd7ebe7.js" as="script"><link rel="prefetch" href="/wb/assets/022101.html-f6317717.js" as="script"><link rel="prefetch" href="/wb/assets/030801.html-cbbde2a3.js" as="script"><link rel="prefetch" href="/wb/assets/032201.html-33e3ac66.js" as="script"><link rel="prefetch" href="/wb/assets/022201.html-963afee1.js" as="script"><link rel="prefetch" href="/wb/assets/030501.html-84913c94.js" as="script"><link rel="prefetch" href="/wb/assets/home.html-3eb4d994.js" as="script"><link rel="prefetch" href="/wb/assets/plugin.html-1483d1d0.js" as="script"><link rel="prefetch" href="/wb/assets/standard.html-14b52c51.js" as="script"><link rel="prefetch" href="/wb/assets/vuePackage.html-0219c43d.js" as="script"><link rel="prefetch" href="/wb/assets/404.html-60b35caa.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-cc91309e.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-605912bc.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-beb31cc7.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-b61a46e1.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-f98e8ff2.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-fa9fcc1d.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-073d6df6.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c3fee9e4.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-52c1909f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-def60933.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-76d7399e.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-cc87ab1a.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-49a24dd3.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-f6c26c3a.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-4a7242ff.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-b00d5359.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-e2ee4194.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-e4115364.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-4521aa3a.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c4b820ea.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-6fdefc04.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-50818995.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-2014b8cd.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-b1dc5ed7.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-2ddb2e51.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-72fa249f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-217d2183.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-0b40087e.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-c52474d7.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-8489252c.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-2407d7b8.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-daf2f840.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-db0ba367.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-0999e780.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-ff3616e1.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-40ca6f0a.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-ba22b693.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-f989ee07.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-d7d4cc9f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-6ee6582b.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-955dcc0f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-5feeb1e7.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-a5819ddb.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-a45e3ca9.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-452ace3c.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-46c84a4f.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-b428ebd7.js" as="script"><link rel="prefetch" href="/wb/assets/index.html-8380941b.js" as="script"><link rel="prefetch" href="/wb/assets/031101.html-b6a75232.js" as="script"><link rel="prefetch" href="/wb/assets/031102.html-7868935d.js" as="script"><link rel="prefetch" href="/wb/assets/031501.html-a7e44746.js" as="script"><link rel="prefetch" href="/wb/assets/122102.html-6865b75f.js" as="script"><link rel="prefetch" href="/wb/assets/010601.html-dad7a79c.js" as="script"><link rel="prefetch" href="/wb/assets/010602.html-7fb1cd64.js" as="script"><link rel="prefetch" href="/wb/assets/010603.html-e563daab.js" as="script"><link rel="prefetch" href="/wb/assets/010604.html-815b9c8a.js" as="script"><link rel="prefetch" href="/wb/assets/010701.html-2b4e145e.js" as="script"><link rel="prefetch" href="/wb/assets/010801.html-b73655fc.js" as="script"><link rel="prefetch" href="/wb/assets/011001.html-2b9771e1.js" as="script"><link rel="prefetch" href="/wb/assets/011201.html-1af6d9d4.js" as="script"><link rel="prefetch" href="/wb/assets/011202.html-9093c19a.js" as="script"><link rel="prefetch" href="/wb/assets/011301.html-a03518e6.js" as="script"><link rel="prefetch" href="/wb/assets/011501.html-e90b5831.js" as="script"><link rel="prefetch" href="/wb/assets/010501.html-2ebe48c4.js" as="script"><link rel="prefetch" href="/wb/assets/031801.html-e190b745.js" as="script"><link rel="prefetch" href="/wb/assets/092102.html-047558e2.js" as="script"><link rel="prefetch" href="/wb/assets/092103.html-3f4ca6b9.js" as="script"><link rel="prefetch" href="/wb/assets/081101.html-c0375214.js" as="script"><link rel="prefetch" href="/wb/assets/092001.html-b2f5f9d7.js" as="script"><link rel="prefetch" href="/wb/assets/092101.html-40dbcdf2.js" as="script"><link rel="prefetch" href="/wb/assets/092102.html-111fa3dd.js" as="script"><link rel="prefetch" href="/wb/assets/092103.html-dfe62a63.js" as="script"><link rel="prefetch" href="/wb/assets/092104.html-6ea8f578.js" as="script"><link rel="prefetch" href="/wb/assets/092105.html-f58f55b7.js" as="script"><link rel="prefetch" href="/wb/assets/122101.html-a20220c8.js" as="script"><link rel="prefetch" href="/wb/assets/122201.html-7699eb69.js" as="script"><link rel="prefetch" href="/wb/assets/092105.html-ea49cb27.js" as="script"><link rel="prefetch" href="/wb/assets/121501.html-4c68ef56.js" as="script"><link rel="prefetch" href="/wb/assets/092101.html-01673776.js" as="script"><link rel="prefetch" href="/wb/assets/092105.html-49fde8c8.js" as="script"><link rel="prefetch" href="/wb/assets/guide.html-85aeb00d.js" as="script"><link rel="prefetch" href="/wb/assets/011301.html-869da26f.js" as="script"><link rel="prefetch" href="/wb/assets/021401.html-ecbb30c7.js" as="script"><link rel="prefetch" href="/wb/assets/022001.html-f65da4af.js" as="script"><link rel="prefetch" href="/wb/assets/022101.html-bf352765.js" as="script"><link rel="prefetch" href="/wb/assets/030801.html-c3885c66.js" as="script"><link rel="prefetch" href="/wb/assets/032201.html-86eb91fa.js" as="script"><link rel="prefetch" href="/wb/assets/022201.html-998fc43b.js" as="script"><link rel="prefetch" href="/wb/assets/030501.html-61615073.js" as="script"><link rel="prefetch" href="/wb/assets/home.html-5d4ac598.js" as="script"><link rel="prefetch" href="/wb/assets/plugin.html-85fb2e2c.js" as="script"><link rel="prefetch" href="/wb/assets/standard.html-52035280.js" as="script"><link rel="prefetch" href="/wb/assets/vuePackage.html-6cc12cdb.js" as="script"><link rel="prefetch" href="/wb/assets/404.html-16732b58.js" as="script"><link rel="prefetch" href="/wb/assets/reco-valine-a0c1af1f.js" as="script">
    <link rel="preload" href="/wb/assets/style-cad7fe2b.css" as="style"><link rel="stylesheet" href="/wb/assets/style-cad7fe2b.css">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><div class="common-wrapper series--no show-catalog"><div><header class="navbar-container"><!--[--><div class="site-brand nav-item"><img class="logo" src="/wb/logo.png" alt="王茂铭"><a href="/wb/" class="site-name can-hide">王茂铭</a></div><div class="nav-item navbar-links-wrapper" style=""><form class="search-box" role="search"><input type="search" autocomplete="off" spellcheck="false" value><!----></form><nav class="navbar-links"><!--[--><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="Categories"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Categories<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="Categories"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Categories<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/wb/categories/shujujiegouyusuanfa/1/" class="link" aria-label="数据结构与算法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->数据结构与算法<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/weiqianduanjiagou/1/" class="link" aria-label="微前端架构"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->微前端架构<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/mianshi/1/" class="link" aria-label="面试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->面试<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/React/1/" class="link" aria-label="React"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->React<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/qianduan/1/" class="link" aria-label="前端"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->前端<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/vue/1/" class="link" aria-label="vue"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vue<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/Angular/1/" class="link" aria-label="Angular"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Angular<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/WebGIS/1/" class="link" aria-label="WebGIS"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->WebGIS<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/gongjuyuyuedu/1/" class="link" aria-label="工具与阅读"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->工具与阅读<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/houduan/1/" class="link" aria-label="后端"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->后端<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="Tags"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Tags<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="Tags"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Tags<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/wb/tags/shujujiegouyusuanfa/1/" class="link" aria-label="数据结构与算法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->数据结构与算法<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/weiqianduanjiagou/1/" class="link" aria-label="微前端架构"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->微前端架构<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/qiankun/1/" class="link" aria-label="qiankun"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->qiankun<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/mianshi/1/" class="link" aria-label="面试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->面试<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/react/1/" class="link" aria-label="react"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->react<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/element/1/" class="link" aria-label="element"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->element<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/tree/1/" class="link" aria-label="tree"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->tree<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/js/1/" class="link" aria-label="js"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->js<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/daimajiqiao/1/" class="link" aria-label="代码技巧"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码技巧<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/vue/1/" class="link" aria-label="vue"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vue<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/diceng/1/" class="link" aria-label="底层"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->底层<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/angular/1/" class="link" aria-label="angular"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->angular<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/echars/1/" class="link" aria-label="echars"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->echars<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/keshihua/1/" class="link" aria-label="可视化"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->可视化<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/gaodeditu/1/" class="link" aria-label="高德地图"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->高德地图<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/shouce/1/" class="link" aria-label="手册"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->手册<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/es6/1/" class="link" aria-label="es6"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->es6<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/qianduan/1/" class="link" aria-label="前端"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->前端<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/jianrongxing/1/" class="link" aria-label="兼容性"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->兼容性<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/node/1/" class="link" aria-label="node"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->node<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/html/1/" class="link" aria-label="html"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->html<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/css/1/" class="link" aria-label="css"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->css<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/python/1/" class="link" aria-label="python"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->python<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/flask/1/" class="link" aria-label="flask"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->flask<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/Objective-C/1/" class="link" aria-label="Objective-C"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Objective-C<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/webpack/1/" class="link" aria-label="webpack"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->webpack<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/git/1/" class="link" aria-label="git"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->git<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/shuji/1/" class="link" aria-label="书籍"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->书籍<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/aihao/1/" class="link" aria-label="爱好"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->爱好<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/wb/" class="link router-link-active" aria-label="首页"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->首页<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/wb/docs/theme-reco/home" class="link" aria-label="公共方法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->公共方法<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/docs/theme-reco/vuePackage" class="link" aria-label="vue组件包"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vue组件包<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/docs/theme-reco/standard" class="link" aria-label="前端代码规范"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->前端代码规范<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><!--]--></nav><span class="xicon-container btn-toggle-dark-mode btn--dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></span><span class="xicon-container btn-toggle-menus"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><circle cx="16" cy="8" r="2" fill="currentColor"></circle><circle cx="16" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="24" r="2" fill="currentColor"></circle></svg></span></div><!--]--></header><div class="mobile-menus-container"><nav class="navbar-links mobile"><!--[--><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="Categories"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Categories<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="Categories"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Categories<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/wb/categories/shujujiegouyusuanfa/1/" class="link" aria-label="数据结构与算法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->数据结构与算法<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/weiqianduanjiagou/1/" class="link" aria-label="微前端架构"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->微前端架构<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/mianshi/1/" class="link" aria-label="面试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->面试<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/React/1/" class="link" aria-label="React"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->React<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/qianduan/1/" class="link" aria-label="前端"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->前端<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/vue/1/" class="link" aria-label="vue"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vue<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/Angular/1/" class="link" aria-label="Angular"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Angular<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/WebGIS/1/" class="link" aria-label="WebGIS"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->WebGIS<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/gongjuyuyuedu/1/" class="link" aria-label="工具与阅读"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->工具与阅读<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/categories/houduan/1/" class="link" aria-label="后端"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->后端<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="Tags"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Tags<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="Tags"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Tags<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/wb/tags/shujujiegouyusuanfa/1/" class="link" aria-label="数据结构与算法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->数据结构与算法<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/weiqianduanjiagou/1/" class="link" aria-label="微前端架构"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->微前端架构<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/qiankun/1/" class="link" aria-label="qiankun"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->qiankun<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/mianshi/1/" class="link" aria-label="面试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->面试<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/react/1/" class="link" aria-label="react"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->react<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/element/1/" class="link" aria-label="element"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->element<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/tree/1/" class="link" aria-label="tree"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->tree<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/js/1/" class="link" aria-label="js"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->js<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/daimajiqiao/1/" class="link" aria-label="代码技巧"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码技巧<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/vue/1/" class="link" aria-label="vue"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vue<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/diceng/1/" class="link" aria-label="底层"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->底层<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/angular/1/" class="link" aria-label="angular"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->angular<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/echars/1/" class="link" aria-label="echars"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->echars<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/keshihua/1/" class="link" aria-label="可视化"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->可视化<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/gaodeditu/1/" class="link" aria-label="高德地图"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->高德地图<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/shouce/1/" class="link" aria-label="手册"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->手册<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/es6/1/" class="link" aria-label="es6"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->es6<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/qianduan/1/" class="link" aria-label="前端"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->前端<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/jianrongxing/1/" class="link" aria-label="兼容性"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->兼容性<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/node/1/" class="link" aria-label="node"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->node<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/html/1/" class="link" aria-label="html"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->html<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/css/1/" class="link" aria-label="css"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->css<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/python/1/" class="link" aria-label="python"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->python<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/flask/1/" class="link" aria-label="flask"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->flask<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/Objective-C/1/" class="link" aria-label="Objective-C"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Objective-C<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/webpack/1/" class="link" aria-label="webpack"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->webpack<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/git/1/" class="link" aria-label="git"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->git<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/shuji/1/" class="link" aria-label="书籍"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->书籍<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/tags/aihao/1/" class="link" aria-label="爱好"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->爱好<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/wb/" class="link router-link-active" aria-label="首页"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->首页<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/wb/docs/theme-reco/home" class="link" aria-label="公共方法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->公共方法<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/docs/theme-reco/vuePackage" class="link" aria-label="vue组件包"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vue组件包<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/wb/docs/theme-reco/standard" class="link" aria-label="前端代码规范"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->前端代码规范<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><!--]--></nav><div class="appearance"><span>Appearance</span><span class="xicon-container btn-toggle-dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></span></div></div><div class="series-mask"></div><aside class="series-container"><div class="site-brand"><img class="logo" src="/wb/logo.png" alt="王茂铭"><a href="/wb/" class="site-name can-hide">王茂铭</a></div><!--[--><!--]--></aside><!--[--><main class="page-container"><h1 class="page-title">objectivec基础用法</h1><div class="page-info"><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M16 4a5 5 0 1 1-5 5a5 5 0 0 1 5-5m0-2a7 7 0 1 0 7 7a7 7 0 0 0-7-7z" fill="currentColor"></path><path d="M26 30h-2v-5a5 5 0 0 0-5-5h-6a5 5 0 0 0-5 5v5H6v-5a7 7 0 0 1 7-7h6a7 7 0 0 1 7 7z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->王茂铭<!--]--></span></span><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2019-09-26<!--]--></span></span><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M11.17 6l3.42 3.41l.58.59H28v16H4V6h7.17m0-2H4a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h24a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2H16l-3.41-3.41A2 2 0 0 0 11.17 4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->后端<!--]--></span></span><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M10 14a4 4 0 1 1 4-4a4.005 4.005 0 0 1-4 4zm0-6a2 2 0 1 0 1.998 2.004A2.002 2.002 0 0 0 10 8z" fill="currentColor"></path><path d="M16.644 29.415L2.586 15.354A2 2 0 0 1 2 13.941V4a2 2 0 0 1 2-2h9.941a2 2 0 0 1 1.414.586l14.06 14.058a2 2 0 0 1 0 2.828l-9.943 9.943a2 2 0 0 1-2.829 0zM4 4v9.942L18.058 28L28 18.058L13.942 4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Objective-C<!--]--></span></span><!----></div><div class="theme-reco-default-content"><div><h1 id="ios" tabindex="-1"><a class="header-anchor" href="#ios" aria-hidden="true">#</a> IOS</h1><h2 id="视图控制器" tabindex="-1"><a class="header-anchor" href="#视图控制器" aria-hidden="true">#</a> 视图控制器</h2><h3 id="基本用法" tabindex="-1"><a class="header-anchor" href="#基本用法" aria-hidden="true">#</a> 基本用法</h3><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code>   CGRect rect1 <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//初始化一个矩形显示区域对象，</span>
    UIView <span class="token operator">*</span>view1 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span>rect1<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个视图对象</span>
    view1<span class="token punctuation">.</span>backgroundColor<span class="token operator">=</span><span class="token punctuation">[</span>UIColor brownColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//颜色设置</span>
    
    CGRect rect2 <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">90</span><span class="token punctuation">,</span> <span class="token number">120</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//初始化一个矩形显示区域对象，</span>
    UIView <span class="token operator">*</span>view2 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span>rect2<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个视图对象</span>
    view2<span class="token punctuation">.</span>backgroundColor<span class="token operator">=</span><span class="token punctuation">[</span>UIColor purpleColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//颜色设置</span>
    
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view1<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到视图控制器的根视图</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view2<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到视图控制器的根视图</span>
视图的层次（父子）

UIView <span class="token operator">*</span>view1 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span><span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">80</span><span class="token punctuation">,</span> <span class="token number">280</span><span class="token punctuation">,</span> <span class="token number">280</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    view1<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor redColor<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view1<span class="token punctuation">]</span><span class="token punctuation">;</span>
    
    UIView <span class="token operator">*</span>view2 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span><span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    view2<span class="token punctuation">.</span>bounds <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">40</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//设置视图本地坐标系统中的位置和大小，会影响子视图的位置和显示</span>
    view2<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor yellowColor<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>view2<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到视图控制器的根视图</span>
    
    UIView <span class="token operator">*</span>view3 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UIView alloc<span class="token punctuation">]</span> initWithFrame<span class="token punctuation">:</span><span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    view3<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor blueColor<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>view2 addSubview<span class="token punctuation">:</span>view3<span class="token punctuation">]</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><img src="/wb/shitu01.png" alt="foo"> ```objectivec 视图的基本添加删除操作 CGRect rect1 = CGRectMake(30, 50, 200, 200);//初始化一个矩形显示区域对象， UIView *view1 = [[UIView alloc] initWithFrame:rect1];//创建一个视图对象 view1.backgroundColor=[UIColor brownColor];//颜色设置 [self.view addSubview:view1]; <pre><code>UIButton *btAdd = [[UIButton alloc] initWithFrame:CGRectMake(30, 350, 80, 30)];//设置一个按钮
btAdd.backgroundColor =[UIColor grayColor];//添加一个按钮颜色
[btAdd setTitle:@&quot;Add&quot; forState:UIControlStateNormal];//设置按钮正常状态下的标题，其他状态还包括按钮被按下等状态
[btAdd addTarget:self action:@selector(addView) forControlEvents:UIControlEventTouchUpInside];//给按钮绑定点击事件，这样点击按钮时，将执行添加视图方法
[self.view addSubview:btAdd];//将按钮添加到视图控制器的根视图
//切换试图顺序
UIButton *btBack = [[UIButton alloc] initWithFrame:CGRectMake(120, 350, 80, 30)];//设置一个按钮
btBack.backgroundColor =[UIColor grayColor];//添加一个按钮颜色
[btBack setTitle:@&quot;Switch&quot; forState:UIControlStateNormal];//设置按钮正常状态下的标题，其他状态还包括按钮被按下等状态
[btBack addTarget:self action:@selector(bringViewBack) forControlEvents:UIControlEventTouchUpInside];//给按钮绑定点击事件，这样点击按钮时，将交换视图的层次
[self.view addSubview:btBack];//将按钮添加到视图控制器的根视图

UIButton *btRemove = [[UIButton alloc] initWithFrame:CGRectMake(210, 350, 80, 30)];//设置一个按钮
btRemove.backgroundColor =[UIColor grayColor];//添加一个按钮颜色
[btRemove setTitle:@&quot;Remove&quot; forState:UIControlStateNormal];//设置按钮正常状态下的标题，其他状态还包括按钮被按下等状态
[btRemove addTarget:self action:@selector(removeView) forControlEvents:UIControlEventTouchUpInside];//给按钮绑定点击事件，这样点击按钮时，将交换视图的层次
[self.view addSubview:btRemove];//将按钮添加到视图控制器的根视图
</code></pre><p>}</p><ul><li><p>(void) addView { CGRect rect = CGRectMake(60, 90, 200, 200);//初始化一个矩形显示区域对象， UIView *view = [[UIView alloc] initWithFrame:rect];//创建一个视图对象 view.backgroundColor=[UIColor purpleColor];//颜色设置 view.tag=1;//给视图指定一个标志，可通过标志找到视图 [self.view addSubview:view];//将按钮添加到视图控制器的根视图 }</p></li><li><p>(void) bringViewBack { UIView *view = [self.view viewWithTag:1];//通过刚刚设置的标志找到新添加的视图 [self.view sendSubviewToBack:view];//将新添加的视图移到所有兄弟视图的后方 }</p></li><li><p>(void) removeView { UIView *view = [self.view viewWithTag:1];//通过刚刚设置的标志找到新添加的视图 [view removeFromSuperview];//将新添加的视图从父视图中删除</p></li></ul><p>}</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>视图编写相框
```objectivec
UIImage *image = [UIImage imageNamed:@&quot;01&quot;];//加载图片
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];//图片的容器
    imageView.frame = CGRectMake(24, 80, 272, 410);//初始化图像位置
    imageView.layer.borderWidth=10;//设置图像视图的图层边框宽度
    imageView.layer.borderColor= [UIColor lightGrayColor].CGColor;//通过访问视图图层属性设置相关属性
    [self.view addSubview:imageView];//将图层添加到视图控制器的根视图
&lt;img :src=&quot;$withBase(&#39;/shitu02.png&#39;)&quot; alt=&quot;foo&quot;&gt; 
添加圆角效果
UIImage *image = [UIImage imageNamed:@&quot;01&quot;];//加载图片
        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];//图片的容器
        imageView.frame = CGRectMake(24, 80, 300, 300);//初始化图像位置
        imageView.layer.cornerRadius=150;//设置圆角为一半
        imageView.layer.masksToBounds=true;//设置图像视图层的遮罩覆盖属性，进行边界裁切
        [self.view addSubview:imageView];//将图层添加到视图控制器的根视图
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><img src="/wb/shitu03.png" alt="foo"> 图像阴影效果 ```objectivec UIImage *image = [UIImage imageNamed:@&quot;01&quot;];//加载图片 UIImageView *imageView = [[UIImageView alloc] initWithImage:image];//图片的容器 imageView.frame = CGRectMake(36, 80, 272,164);//初始化图像位置 imageView.layer.shadowColor =[UIColor blackColor].CGColor;//阴影颜色为黑色 imageView.layer.shadowOffset = CGSizeMake(10.0, 10.0);//设置横向和纵向偏移 imageView.layer.shadowOpacity=0.45;//阴影透明度 imageView.layer.shadowRadius=10;//阴影半径大小 [self.view addSubview:imageView]; ``` <img src="/wb/shitu04.png" alt="foo"> 渐变填充 ``` CGRect rect =CGRectMake(30, 60, 200, 200); UIView *view = [[UIView alloc] initWithFrame:rect];//创建一个视图对象 CAGradientLayer *viewlayer =[CAGradientLayer layer];//新建一个渐变层 viewlayer.frame = view.frame;//设置渐变层的位置和尺寸，与视图对象一致 CGContextRef fromcolor = [UIColor yellowColor].CGColor;//渐变的开始颜色 CGContextRef midcolor = [UIColor redColor].CGColor;//中间颜色 CGContextRef tocolor = [UIColor purpleColor].CGColor;//结束颜色 <pre><code>viewlayer.colors = [NSArray arrayWithObjects:(__bridge id)(fromcolor), midcolor,tocolor,nil];//将渐变层颜色数组属性，设置y为由三个颜色所构建的数组
[view.layer addSublayer:viewlayer];//将配置好的渐变层添加到视图对象层
[self.view addSubview:view];
</code></pre><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>&lt;img :src=&quot;$withBase(&#39;/shitu05.png&#39;)&quot; alt=&quot;foo&quot;&gt; 
## 基本语法
### import指令
1）以#开头，是一个预处理指令，预处理指令表示在编译之前执行
2）作用：是#include指令的增强版。用于包含文件。将文件的内容拷贝到写指令的地方。
3）增强：同一个文件无论#import多少次，只会包含一次该文件
如果#include指令执行多少次就会包含多少次，当然想要实现与#import一样的效果必须配合条件编译指		 令来实现。
4）简要原理：#import指令在包含文件的时候，底层会先判断这个文件是否被包含，如果被包含就会略过，否则会包含。 
### 框架
1）一个功能集  ——苹果或者第三方事先将一些程序在来发程序的时候经常要用到的功能事先写好。把这些功能封装在1个1个的类或者函数之中，这些函数和类的集合叫做框架。
2）Foundation框架
Foundation：基础，这个框架提供了一些最基础的功能 输入输出、一些数据类型
@autoreleasepool是自动释放池
### NSLog函数
1）作用：是printf函数的增强版，向控制台输出信息
2）语法：
                   NSLog(@&quot;格式控制字符串&quot;,变量列表)
      最简单的语法：
                  NSLog(@&quot;要输出的信息&quot;)   
3）增强：
       a.输出一些调试相关的信息    【时间、程序名称、进程编号：线程编号】NSLog输出的信息
       b.会自动换行
       c.OC新增了一些数据类型
### NSString
OC字符串常量必须使用1个@前缀符号，
NSString类型的指针变量，只能储存OC字符串的地址
NSString *str;指针变量前面要加一个星号
NSString *str=@&quot;jack&quot;;
### 注意
OC字符串必须加@符号——NSLog(@&quot;你好&quot;)
如果要使用占位符做字符串拼接要使用%@
NSLog(@&quot;你好，我是%@&quot;,str)
NS前缀
 OC语言的发展：NextStep——》Cocoa——》Foundation框架之中
就是以NextStep命名的前缀
### @符号
1）将C字符串转换为OC字符串
&quot;jack&quot; =》 @&quot;jack&quot;
2）OC中的绝大部分关键字都是以@符号开头

1.OC程序的命令行-编译、连接、执行。
1）.在.m文件中写上符合OC语法规范的源代码
2）.使用编译器将源代码编译为目标文件
     cc  -c xx.m
     a.预处理
     b.检查语法
     c.编译
3）.链接
     cc  xx.o
     如果程序中使用到框架中的函数或者类，那么在链接的时候，必须告诉编译器去那个框架中找这个函数或者类。 
     cc  xx.o  -framework  框架名
     程序中用到那个框架中的功能，那么就在那个地方告诉编译器 
4）.链接成功以后，就会生成1个a.out可执行文件，执行就可以
2.OC程序和C程序各个阶段的后缀名对比
              源文件             目标文件         可执行文件
C                .c                        .o                    .out
OC             .m                        .o                    .out
3.OC中的数据类型
1）.OC中支持C语言中的所有数据类型。
a.基本数据类型
int 	double	float	 	char
b.构造类型
数组		结构体	枚举
c.指针类型
int  *p1
d.空类型
void
e.typedef自定义类型
给已有的数据类型去一个别名
2）.BOOL类型
1）可以存储YES或者NO中任意一个数据，要大写
2）.一般情况下BOOL类型的变量用来存储条件表达式的结果是否成立
3）.BOOL的本质
typedef  signed char BOOL
实际上BOOL类型的变量 是一个有符号的char变量

#define YES ((BOOL)1)     		
#define NO   ((BOOL)0)
 
YES   实际是1
NO     实际是0
3）.Boolean类型
a.可以存储true 或者flase
b.一般情况下Boolean类型的变量用来存储条件表达式的结果是否成立
c.本质
    typedef  unsigned char Boolean   是一个无符号的char类型
       define YES   1     		
define NO     0
4）.class类型、类
5）.id类型  万能指针
6）.nil与NULL差不多
7）.SEL方法选择器
8）.block代码段类型
面向过程与面向对象
其实是解决同一个问题的不同的两种思路。注重的过程或者对象
1）.面向过程
在遇到一个需求的时候，实现这个需求的每一个步骤都是自己写代码亲自一步一步的走
2）.面向对象
在遇到一个需求的时候，不用亲自去实现，而是找一个专门做这个事情的人来帮助我们完成
### 优缺点分析：
C语言是一门面向过程的语言
OC语言是一门面向对象的语言

面向过程的缺点：后期的维护和修改不方便
面向对象的优点：后期的维护和修改十分方便
面向对象的思维解决问题
当你遇到一个需求的时候，不要亲自去实现。
1）.先看看有没有现成的人专门做这件事情。例如框架。
2）.如果没有就自己造一个拥有这样功能的人。可以多次使用
### 类和对象
对象：是现实生活中一个具体存在，看得见、摸得着，拿过来就可以用
类：物以类聚  人以群分
是对一群具有相同特征或者行为的事物的统称
类和对象的关系：
类是模板，类的对象是根据这个模板创建出来的
类模板中有什么，对象中就有什么 绝不可能多 也绝不可能少
如何设计有一个类
类的作用：用来描述一群具有相同特征和行为的事物
设计类的三要素：
类的名字：要描述的这类事物叫什么名字
这类事物具有相同的特征。拥有什么
这类事物具有的共同的行为，做什么
如何找到类
名词提炼法：分析整个业务流程，分析出现哪些名词，这些名词就是类
先有类还是先有对象：
从现实的角度  一定是先有对象再有类
从现实的角度  一定是先有类在有对象
 定义类的语法
a.写在源文件之中 不要写在man函数中
b.类的定义分为两个部分
类的声明
```objectivec
@inteface 类名  ：NSObject
{
//这类事物具有相同的特征，将他们定义为变量
}
//功能就是一个方法，将方法的声明写在这儿
@end
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>类的实现</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token keyword">@implementation</span>  类名
将方法的实现写在这里
<span class="token keyword">@end</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>》几点注意： a.类必须要有声明和实现， b.类名用你描述的事物的名称来命名，不过名字必须是首字母大写 c.用来表示事物特征的变量（属性、成员变量、实例变量等叫法），要放在{}之中 d.为类定义属性的时候，定义的属性名一下划线开头，是一种开发规范 e.类是没法直接使用的，非要使用这个类的话，要先使用这个类中的一个具体存在，再使用这个 对象 》如何创建一个类的对象呢？ 语法：类名 *对象名 = [类名 new] 在main里面写 Person *p1 = [Person new] 》如何使用对象 如何去访问对象里面的属性： 1）.默认情况下，不允许直接访问对象里面的属性 如果允许对象的属性可以被外界访问，那么就在声明属性的时候加一个@public关键字 2）.访问对象的属性的方式 平时使用： 对象名-&gt;属性名=值；//赋值 对象名-&gt;属性名；//找到属性名的值 p1-&gt;_name=@&quot;小王&quot; 另外一种方法： (*对象名).属性名=值； (*p1)._name=@&quot;小王&quot;</p><h3 id="类的声明" tabindex="-1"><a class="header-anchor" href="#类的声明" aria-hidden="true">#</a> 类的声明</h3><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token keyword">@interface</span> Person <span class="token punctuation">:</span>NSObject
<span class="token punctuation">{</span>
<span class="token keyword">@public</span>			<span class="token comment">//允许对象访问属性</span>
NSString <span class="token operator">*</span>_name<span class="token punctuation">;</span>
<span class="token keyword">int</span> _age<span class="token punctuation">;</span>
<span class="token keyword">float</span> _height<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
方法的声明写的位置
<span class="token keyword">@end</span>
类的实现
<span class="token keyword">@implementation</span> Person
方法的实现
<span class="token keyword">@end</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>占位符：%@ %d 方法的声明实现调用 方法和函数都表示对象的一个功能，OC的行为我们用方法来表示 1）无参数的方法 声明： 位置：在@interface Person :NSObject{}之外 语法：- (返回值类型)方法名称</p><ul><li>(void)run //该方法如果没有返回值没有返回值，则使用void 实现： 位置：在@implementation Person之中 语法：将方法的声明拷贝到@implementation之中，去掉分号，追加一个大括号，在大括号中写</li><li>(void)run{ NSLog(@&quot;我是人，我在跑&quot;) } 调用： a.方法是无法直接调用的，因为类是不能直接使用的，必须要先创建对象。那么这个对象中就有类中的属性和方法了 就可以调用对象的方法了 b.调用对象的方法： [对象名 方法名] Person *p1 = [Person new]//声明一个对象 [p1 run]//调用 2）带一个参数的方法 声明： 位置：在@interface Person :NSObject{}之外 语法：- (返回值类型)方法名称:(参数的类型)形参的名称</li><li>(void)eat:(NSString <em>) foodName //NSString指针加</em>，定义了一个没有返回值的方法，方法的名字叫eat:,有一个参数，类型是NSString * 参数名foodName 实现： 位置：在@implementation Person之中 语法：将方法的声明拷贝到@implementation之中，去掉分号，追加一个大括号，在大括号中写</li></ul><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span>eat<span class="token punctuation">:</span><span class="token punctuation">(</span>NSString <span class="token operator">*</span><span class="token punctuation">)</span> foodName<span class="token punctuation">{</span>
 	<span class="token function">NSLog</span><span class="token punctuation">(</span><span class="token string">@&quot;你给的%@好吃&quot;</span>，foodName<span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>调用： a.方法是无法直接调用的，因为类是不能直接使用的，必须要先创建对象。那么这个对象中就有类中的属性和方法了 就可以调用对象的方法了 b.调用对象的方法： [对象名 方法名：实参] Person *p1 = [Person new]//声明一个对象 [p1 eat:@&quot;红烧排骨&quot;]//调用 3)带多个参数的方法 声明： 位置：在@interface Person :NSObject{}之外 语法：- (返回值类型)方法名称:(参数的类型)形参名称1 :(参数的类型)形参名称2 :(参数的类型)形参名称3</p><ul><li>(int)sum:(int) num1 :(int) num2 表示声明了1个方法，这个方法的返回值类型是int类型的，方法名称叫做 sum: : 有两个参数 参数类型都是int类型 参数名称叫做num1 num2 实现： 位置：在@implementation Person之中 语法：将方法的声明拷贝到@implementation之中，去掉分号，追加一个大括号，在大括号中写</li><li>(int)sum:(int) num1 :(int) num2 { int num3=num1+num2; return num3 } 调用： a.方法是无法直接调用的，因为类是不能直接使用的，必须要先创建对象。那么这个对象中就有类中的属性和方法了 就可以调用对象的方法了 b.调用带多个参数的语法： [对象名 方法名：实参1 ：实参2] Person *p1 = [Person new]//声明一个对象 int sum = [p1 sum:10 :20]//调用 NSLog(@&quot;sum=%d&quot;,sum) 4)带参数的方法声明的规范： 1）如果方法只有一个参数，要求最好这个方法的名字叫做xxxWith: 或者xxxWithxxx 这样写就会看起来像一条完整的语句，提高代码的阅读性 2)如果方法有多个参数，方法名最好是 方法名With:(参数类型)参数名称1 and:(参数类型)参数名称2 and:(参数类型)参数名称3 - (int)sumWith:(int) num1 and :(int) num2 更详细的写法： 方法名With参数1:(参数类型)参数名称1 and参数2:(参数类型)参数名称2<br> - (int)sumWithNum1:(int) num1 andNum2 :(int) num2</li></ul><h2 id="常用控件" tabindex="-1"><a class="header-anchor" href="#常用控件" aria-hidden="true">#</a> 常用控件</h2><h3 id="button控件" tabindex="-1"><a class="header-anchor" href="#button控件" aria-hidden="true">#</a> Button控件</h3><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code>    bt1<span class="token punctuation">.</span>frame <span class="token operator">=</span>  <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">130</span><span class="token punctuation">,</span><span class="token number">80</span><span class="token punctuation">,</span><span class="token number">40</span><span class="token punctuation">,</span><span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//设置按钮位置</span>
    UIButton <span class="token operator">*</span>bt2 <span class="token operator">=</span> <span class="token punctuation">[</span>UIButton buttonWithType<span class="token punctuation">:</span>UIButtonTypeRoundedRect<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置一个普通的圆角按钮</span>
    bt2<span class="token punctuation">.</span>frame <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">,</span> <span class="token number">180</span><span class="token punctuation">,</span> <span class="token number">150</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    bt2<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor purpleColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的背景色</span>
   bt2<span class="token punctuation">.</span>tintColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor yellowColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的前景颜色</span>
    <span class="token punctuation">[</span>bt2 setTitle<span class="token punctuation">:</span><span class="token string">@&quot;按钮2&quot;</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的标题文字</span>
    <span class="token punctuation">[</span>bt2 addTarget<span class="token punctuation">:</span><span class="token keyword">self</span> action<span class="token punctuation">:</span><span class="token keyword">@selector</span><span class="token punctuation">(</span>buttontap<span class="token punctuation">:</span><span class="token punctuation">)</span> forControlEvents<span class="token punctuation">:</span>UIControlEventTouchUpInside<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//给按钮绑定点击的动作</span>
    UIButton <span class="token operator">*</span>bt3 <span class="token operator">=</span> <span class="token punctuation">[</span>UIButton buttonWithType<span class="token punctuation">:</span>UIButtonTypeRoundedRect<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置一个普通的圆角按钮</span>
    bt3<span class="token punctuation">.</span>frame <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">,</span> <span class="token number">280</span><span class="token punctuation">,</span> <span class="token number">150</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    bt3<span class="token punctuation">.</span>backgroundColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor brownColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的背景色</span>
    bt3<span class="token punctuation">.</span>tintColor <span class="token operator">=</span> <span class="token punctuation">[</span>UIColor whiteColor<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的前景颜色</span>
    <span class="token punctuation">[</span>bt2 setTitle<span class="token punctuation">:</span><span class="token string">@&quot;按钮3&quot;</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的标题文字</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>masksToBounds<span class="token operator">=</span>YES<span class="token punctuation">;</span><span class="token comment">//给按钮添加边框效果</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>cornerRadius<span class="token operator">=</span><span class="token number">10</span><span class="token punctuation">;</span><span class="token comment">//设置圆角半径</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>borderWidth<span class="token operator">=</span><span class="token number">4</span><span class="token punctuation">;</span><span class="token comment">//宽度</span>
    bt3<span class="token punctuation">.</span>layer<span class="token punctuation">.</span>borderColor<span class="token operator">=</span><span class="token punctuation">[</span>UIColor lightGrayColor<span class="token punctuation">]</span><span class="token punctuation">.</span>CGColor<span class="token punctuation">;</span><span class="token comment">//设置按钮层边框的颜色浅灰</span>

    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt1<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt2<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt3<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>
<span class="token operator">-</span> <span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span> buttontap<span class="token punctuation">:</span><span class="token punctuation">(</span>UIButton <span class="token operator">*</span><span class="token punctuation">)</span>button
<span class="token punctuation">{</span>
   UIAlertController <span class="token operator">*</span>alert <span class="token operator">=</span> <span class="token punctuation">[</span>UIAlertController alertControllerWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;信息&quot;</span> message<span class="token punctuation">:</span><span class="token string">@&quot;警告！！！&quot;</span> preferredStyle<span class="token punctuation">:</span>UIAlertControllerStyleAlert<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//警告弹出窗口</span>
   UIAlertAction <span class="token operator">*</span>okaction <span class="token operator">=</span><span class="token punctuation">[</span>UIAlertAction actionWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;关闭&quot;</span> style<span class="token punctuation">:</span>UIAlertActionStyleDefault handler<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个按钮，作为提示窗口的q确定按钮，当用户点击该按钮时，将关闭提示窗口</span>
   <span class="token punctuation">[</span>alert addAction<span class="token punctuation">:</span>okaction<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到提示窗口</span>
   <span class="token punctuation">[</span><span class="token keyword">self</span> presentViewController<span class="token punctuation">:</span>alert  animated<span class="token punctuation">:</span>YES completion<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="图片按钮" tabindex="-1"><a class="header-anchor" href="#图片按钮" aria-hidden="true">#</a> 图片按钮</h3><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code>    UIButton <span class="token operator">*</span>bt2 <span class="token operator">=</span> <span class="token punctuation">[</span>UIButton buttonWithType<span class="token punctuation">:</span>UIButtonTypeRoundedRect<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置一个普通的圆角按钮</span>
    bt2<span class="token punctuation">.</span>frame <span class="token operator">=</span> <span class="token function">CGRectMake</span><span class="token punctuation">(</span><span class="token number">31</span><span class="token punctuation">,</span> <span class="token number">180</span><span class="token punctuation">,</span> <span class="token number">150</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    UIImage <span class="token operator">*</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;01&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>bt2 setBackgroundImage<span class="token punctuation">:</span>image forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//指定为正常状态下的背景图片</span>
    <span class="token punctuation">[</span>bt2 setTitle<span class="token punctuation">:</span><span class="token string">@&quot;按钮2&quot;</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//设置按钮的标题文字</span>
    <span class="token punctuation">[</span>bt2 setTitleColor<span class="token punctuation">:</span><span class="token punctuation">[</span>UIColor whiteColor<span class="token punctuation">]</span> forState<span class="token punctuation">:</span>UIControlStateNormal<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//标题颜色</span>
    bt2<span class="token punctuation">.</span>titleLabel<span class="token punctuation">.</span>font <span class="token operator">=</span> <span class="token punctuation">[</span>UIFont fontWithName<span class="token punctuation">:</span><span class="token string">@&quot;Arail&quot;</span> size<span class="token punctuation">:</span><span class="token number">24</span><span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//文字字体与大小</span>
    <span class="token punctuation">[</span>bt2 addTarget<span class="token punctuation">:</span><span class="token keyword">self</span> action<span class="token punctuation">:</span><span class="token keyword">@selector</span><span class="token punctuation">(</span>buttontap<span class="token punctuation">:</span><span class="token punctuation">)</span> forControlEvents<span class="token punctuation">:</span>UIControlEventTouchUpInside<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//给按钮绑定点击的动作</span>

    <span class="token punctuation">[</span><span class="token keyword">self</span><span class="token punctuation">.</span>view addSubview<span class="token punctuation">:</span>bt2<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token operator">-</span> <span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span> buttontap<span class="token punctuation">:</span><span class="token punctuation">(</span>UIButton <span class="token operator">*</span><span class="token punctuation">)</span>bt
<span class="token punctuation">{</span>
    UIAlertController <span class="token operator">*</span>alert <span class="token operator">=</span> <span class="token punctuation">[</span>UIAlertController alertControllerWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;信息&quot;</span> message<span class="token punctuation">:</span><span class="token string">@&quot;警告！！！&quot;</span> preferredStyle<span class="token punctuation">:</span>UIAlertControllerStyleAlert<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//警告弹出窗口</span>
    UIAlertAction <span class="token operator">*</span>okaction <span class="token operator">=</span><span class="token punctuation">[</span>UIAlertAction actionWithTitle<span class="token punctuation">:</span><span class="token string">@&quot;关闭&quot;</span> style<span class="token punctuation">:</span>UIAlertActionStyleDefault handler<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//创建一个按钮，作为提示窗口的q确定按钮，当用户点击该按钮时，将关闭提示窗口</span>
    <span class="token punctuation">[</span>alert addAction<span class="token punctuation">:</span>okaction<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//添加到提示窗口</span>
    <span class="token punctuation">[</span><span class="token keyword">self</span> presentViewController<span class="token punctuation">:</span>alert  animated<span class="token punctuation">:</span>YES completion<span class="token punctuation">:</span>nil<span class="token punctuation">]</span><span class="token punctuation">;</span><span class="token comment">//</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="开发问题" tabindex="-1"><a class="header-anchor" href="#开发问题" aria-hidden="true">#</a> 开发问题</h2><h3 id="解决uitableview中cell重用" tabindex="-1"><a class="header-anchor" href="#解决uitableview中cell重用" aria-hidden="true">#</a> 解决UITableView中Cell重用</h3><p>tableView的常规配置，当超出一屏的cell就会标上可重用的标识出列到可重用缓存池中，后面再根据可重用标识来到的可重的cell就会和前面显示同样内容。</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath <span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>

    <span class="token comment">// 定义唯一标识</span>

    <span class="token keyword">static</span> NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token string">@&quot;Cell&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">// 通过唯一标识创建cell实例</span>

    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView dequeueReusableCellWithIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token comment">// 对cell 进行简单地数据配置</span>

   cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

  cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

  cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

  <span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>方法一： 取消cell的重用机制，通过indexPath来创建cell 将可以解决重复显示问题 不过这样做相对于大数据来说内存就比较吃紧了,通过不让它重用cell，来解决重复显示</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath <span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>

    <span class="token comment">// 定义唯一标识</span>

    <span class="token keyword">static</span> NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token string">@&quot;Cell&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">// 通过indexPath创建cell实例 每一个cell都是单独的</span>

    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span>indexPath<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
 cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token comment">// 对cell 进行简单地数据配置</span>

    cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

    cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

    cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>方法二： 让每个cell都拥有一个对应的标识 这样做也会让cell无法重用 所以也就不会是重复显示了 显示内容比较多时内存占用也是比较多的和方案一类似，同样通过不让它重用cell来解决重复显示，不同的每个cell对应一个重用标识</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath<span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>
    <span class="token comment">// 定义cell标识  每个cell对应一个自己的标识</span>
    NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token punctuation">[</span>NSString stringWithFormat<span class="token punctuation">:</span><span class="token string">@&quot;cell%ld%ld&quot;</span><span class="token punctuation">,</span>indexPath<span class="token punctuation">.</span>section<span class="token punctuation">,</span>indexPath<span class="token punctuation">.</span>row<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 通过不同标识创建cell实例</span>
    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView dequeueReusableCellWithIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>


<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// 对cell 进行简单地数据配置</span>
    cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>
    cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>
    cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>方法三： 只要最后一个显示的cell内容不为空，然后把它的子视图全部删除，等同于把这个cell单独出来了 然后跟新数据就可以解决重复显示，同样通过不让他重用cell来解决重复显示，不同的每个cell对应一个标识。</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token operator">-</span> <span class="token punctuation">(</span>UITableViewCell <span class="token operator">*</span><span class="token punctuation">)</span>tableView<span class="token punctuation">:</span><span class="token punctuation">(</span>UITableView <span class="token operator">*</span><span class="token punctuation">)</span>tableView cellForRowAtIndexPath<span class="token punctuation">:</span><span class="token punctuation">(</span>NSIndexPath <span class="token operator">*</span><span class="token punctuation">)</span>indexPath<span class="token punctuation">{</span>

    <span class="token comment">// 定义唯一标识</span>

    <span class="token keyword">static</span> NSString <span class="token operator">*</span>CellIdentifier <span class="token operator">=</span> <span class="token string">@&quot;Cell&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">// 通过唯一标识创建cell实例</span>

    UITableViewCell <span class="token operator">*</span>cell <span class="token operator">=</span> <span class="token punctuation">[</span>tableView dequeueReusableCellWithIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token comment">// 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>cell<span class="token punctuation">)</span> <span class="token punctuation">{</span>
cell <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>UITableViewCell alloc<span class="token punctuation">]</span>initWithStyle<span class="token punctuation">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span class="token punctuation">:</span>CellIdentifier<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>

<span class="token comment">//当页面拉动的时候 当cell存在并且最后一个存在 把它进行删除就出来一个独特的cell我们在进行数据配置即可避免</span>

<span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token punctuation">[</span>cell<span class="token punctuation">.</span>contentView<span class="token punctuation">.</span>subviews lastObject<span class="token punctuation">]</span> <span class="token operator">!=</span> nil<span class="token punctuation">)</span> <span class="token punctuation">{</span>

 <span class="token punctuation">[</span><span class="token punctuation">(</span>UIView <span class="token operator">*</span><span class="token punctuation">)</span><span class="token punctuation">[</span>cell<span class="token punctuation">.</span>contentView<span class="token punctuation">.</span>subviews lastObject<span class="token punctuation">]</span> removeFromSuperview<span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token comment">// 对cell 进行简单地数据配置</span>

cell<span class="token punctuation">.</span>textLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

cell<span class="token punctuation">.</span>detailTextLabel<span class="token punctuation">.</span>text <span class="token operator">=</span> <span class="token string">@&quot;text&quot;</span><span class="token punctuation">;</span>

cell<span class="token punctuation">.</span>imageView<span class="token punctuation">.</span>image <span class="token operator">=</span> <span class="token punctuation">[</span>UIImage imageNamed<span class="token punctuation">:</span><span class="token string">@&quot;4.png&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>    

<span class="token keyword">return</span> cell<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="afnetworking-v3-0-封装和使用" tabindex="-1"><a class="header-anchor" href="#afnetworking-v3-0-封装和使用" aria-hidden="true">#</a> AFNetworking V3.0+ 封装和使用</h3><p>AFNetworking是一个非常方便的iOS网络请求库，可以轻松实现网络请求。这里只实现AFNetworking框架的一丁点功能，不过也够开发一个app了。可以实现的请求方式：POST / GET / PUT / PATCH / DELETE；也可以加载网络图片等。可回调成功和失败结果。封装类在github上的AFNetworkingDemo上，里面的代码可能随着AFNetworking更新而更新，可下载直接使用。</p><p>第一步：从github上面下载AFNetworking库，https://github.com/AFNetworking/AFNetworking 第二步：将下面的文件导入自己搭建的工程里面! <img src="/wb/AFNetworking01.png" alt="foo"> 第三步：要新建一个类，用来管理AFNetworking，这个类的代码在网上很多，可以自行查阅，我自己用的是，AFNetworking_RequestData.m和AFNetworking_RequestData.h，新建一个AFNetworking_RequestData文件夹将这两个文件导入。之后我们需要发送网络请求，调用接口的时候就#import &quot;AFNetworking_RequestData.h&quot;。 第四步：配置支持IOS9，Xcode7的http请求 找到Info.plist文件，右键Open As-Source Code。添加NSAppTransportSecurity项。代码如下：</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code><span class="token operator">&lt;</span>key<span class="token operator">&gt;</span>NSAppTransportSecurity<span class="token operator">&lt;</span><span class="token operator">/</span>key<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>dict<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>key<span class="token operator">&gt;</span>NSAllowsArbitraryLoads<span class="token operator">&lt;</span><span class="token operator">/</span>key<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>true<span class="token operator">/</span><span class="token operator">&gt;</span> <span class="token operator">&lt;</span><span class="token operator">/</span>dict<span class="token operator">&gt;</span>  
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><img src="/wb/AFNetworking02.png" alt="foo"> 第五步：在需要进行网络请求的地方，#import &quot;AFNetworking_RequestData.h&quot; 举例：#import &quot;AFNetworking_RequestData.h&quot; <p>请求url -- #define Game_Timer @&quot;http://live.3g.qq.com/g/s?aid=action_api&amp;module=nba&amp;action=schedule&amp;md=&amp;ds=5&amp;sid=&quot; ///--在点击事件中调用方法，这个方法里面执行下面几句话： [AFNetworking_RequestData requestMethodGetUrl:Game_Timer dic:nil Succed:^(id responseObject) { NSLog(@&quot;%@&quot;,responseObject); } failure:^(NSError *error) { NSLog(@&quot;%@&quot;,error); }];</p><h4 id="afnetworking-请求头的配置用来完成http-basic-auth的鉴权" tabindex="-1"><a class="header-anchor" href="#afnetworking-请求头的配置用来完成http-basic-auth的鉴权" aria-hidden="true">#</a> AFNetWorking 请求头的配置用来完成HTTP Basic Auth的鉴权</h4><p>AFNetWorking 请求头的配置用来完成HTTP Basic Auth的鉴权</p><p>前文中有关于使用AFNetWorking这个代码库来搭建项目的网络协议，但是缺少关于网络请求头方面的知识，现在将其完善。</p><p>AFNetWorking 3.0之前设置请求头：</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code>
perationManager <span class="token operator">*</span>manager <span class="token operator">=</span> <span class="token punctuation">[</span>AFHTTPRequestOperationManager manager<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>securityPolicy <span class="token operator">=</span> <span class="token punctuation">[</span>AFSecurityPolicy policyWithPinningMode<span class="token punctuation">:</span>AFSSLPinningModeNone<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer <span class="token operator">=</span> <span class="token punctuation">[</span>AFJSONRequestSerializer serializer<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>responseSerializer <span class="token operator">=</span> <span class="token punctuation">[</span>AFJSONResponseSerializer serializer<span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;application/json&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Accept&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>  
 
<span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;application/json; charset=utf-8&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Content-Type&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

AFNetWorking <span class="token number">3.0</span>之后设置请求头，更加详细，POST和GET都可以：

<span class="token operator">-</span><span class="token punctuation">(</span>AFHTTPSessionManager<span class="token operator">*</span><span class="token punctuation">)</span>defaultHTTPManager
<span class="token punctuation">{</span>
    <span class="token comment">// 初始化对象</span>
    AFHTTPSessionManager <span class="token operator">*</span>manager <span class="token operator">=</span> <span class="token punctuation">[</span>AFHTTPSessionManager manager<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 返回的格式 JSON</span>
    manager<span class="token punctuation">.</span>responseSerializer <span class="token operator">=</span> <span class="token punctuation">[</span>AFJSONResponseSerializer serializer<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 可接受的文本参数规格</span>
    manager<span class="token punctuation">.</span>responseSerializer<span class="token punctuation">.</span>acceptableContentTypes <span class="token operator">=</span>  <span class="token punctuation">[</span>NSSet setWithObjects<span class="token punctuation">:</span><span class="token string">@&quot;application/json&quot;</span><span class="token punctuation">,</span> <span class="token string">@&quot;text/html&quot;</span><span class="token punctuation">,</span><span class="token string">@&quot;text/json&quot;</span><span class="token punctuation">,</span><span class="token string">@&quot;text/javascript&quot;</span><span class="token punctuation">,</span> nil<span class="token punctuation">]</span><span class="token punctuation">;</span>
    
    <span class="token comment">// 开始设置请求头</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;application/json&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Content-Type&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;填写系统版本&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;sysVersion&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;填写设备&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;deviceModel&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span><span class="token string">@&quot;填写App版本&quot;</span> forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;appVersion&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    
    <span class="token comment">// uid是每个用户对应的ID  cipherText是密码</span>
    NSString <span class="token operator">*</span> part1 <span class="token operator">=</span> <span class="token punctuation">[</span>NSString stringWithFormat<span class="token punctuation">:</span><span class="token string">@&quot;%lld:%@&quot;</span><span class="token punctuation">,</span>uid<span class="token punctuation">,</span>cipherText<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 通过 ID ：密码 的格式，用Basic 的方式拼接成字符串</span>
    NSString <span class="token operator">*</span> authorization <span class="token operator">=</span> <span class="token punctuation">[</span>NSString stringWithFormat<span class="token punctuation">:</span><span class="token string">@&quot;Basic %@&quot;</span><span class="token punctuation">,</span><span class="token punctuation">[</span>part1 base64Encode<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 设置Authorization的方法设置header</span>
    <span class="token punctuation">[</span>manager<span class="token punctuation">.</span>requestSerializer setValue<span class="token punctuation">:</span>authorization forHTTPHeaderField<span class="token punctuation">:</span><span class="token string">@&quot;Authorization&quot;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// 或者直接调用AF的方法进行设置</span>
<span class="token comment">//    - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username</span>
<span class="token comment">//       password:(NSString *)password</span>
<span class="token comment">//    {</span>
<span class="token comment">//        NSData *basicAuthCredentials = [[NSString stringWithFormat:@&quot;%@:%@&quot;, username, password] dataUsingEncoding:NSUTF8StringEncoding];</span>
<span class="token comment">//        NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0];</span>
<span class="token comment">//        [self setValue:[NSString stringWithFormat:@&quot;Basic %@&quot;, base64AuthCredentials] forHTTPHeaderField:@&quot;Authorization&quot;];</span>
<span class="token comment">//    }</span>
    <span class="token keyword">return</span> manager<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>其实最重要的注释中设置请求部分。</p><p>我们可以在前面关于使用AFNetWorking配置网络请求的文章中，AFNetworking_RequestData.m文件中设置头文件。 <img src="/wb/AFNetworking03.png" alt="foo"> 此处只是写死的两个头请求。</p><h3 id="afnetworking3-0带参数请求体以及带请求头" tabindex="-1"><a class="header-anchor" href="#afnetworking3-0带参数请求体以及带请求头" aria-hidden="true">#</a> AFNetworking3.0带参数请求体以及带请求头</h3><p>关于使用AFNetworking3.0带参数请求体以及带请求头的自己封装</p><p>在这里请允许我发句牢骚，真的难搞，不过我首先说好AFNetworking库应该是一个很好的库了。</p><p>首先最重要的一点是：parameters:dic 这句代码中请求体dic我们只需要传NSDictionary *paramDict = @{@&quot;mobile&quot;:mobile,@&quot;pwd&quot;:pwd};类似的对象就可以了，因为AFNetworking库会自动对其序列化。 我与服务器的约定是在新建两个请求头，一个头是当前时间戳，一个是当前时间戳+请求体+一个固定字符串 困扰我很久的其实是以下几点： 第一点：请求头中[manager.requestSerializer setValue:@&quot;application/x-www-form-urlencoded&quot; forHTTPHeaderField:@&quot;Content-Type&quot;];应该是设置application/x-www-form-urlencoded&quot;，而不是application/json&quot; 第二点其实还是请求头，问题就是出在请求体中。NSDictionary *paramDict = @{@&quot;mobile&quot;:mobile,@&quot;pwd&quot;:pwd};这句话得到的是一个带有空格的对象，所以parameters:dic会是一个带空格的对象。 这里我们需要自己写一个方法将对象拼接成json字符串，</p><p>NSDictionary 转Json 去掉换行去掉空格</p><p>//系统自带</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code>NSError <span class="token operator">*</span> error<span class="token punctuation">;</span>
 NSData <span class="token operator">*</span> jsonData <span class="token operator">=</span> <span class="token punctuation">[</span>NSJSONSerialization dataWithJSONObject<span class="token punctuation">:</span>dictionary options<span class="token punctuation">:</span>kNilOptions error<span class="token punctuation">:</span><span class="token operator">&amp;</span>error<span class="token punctuation">]</span><span class="token punctuation">;</span>
 NSString <span class="token operator">*</span> jsonStr <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">[</span>NSString alloc<span class="token punctuation">]</span> initWithData<span class="token punctuation">:</span>jsonData encoding<span class="token punctuation">:</span>NSUTF8StringEncoding<span class="token punctuation">]</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这个会将对象转化成字符串，也就是序列化，但是还是有空格存在，所以是不可取的。</p><p>//自定义一个</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>NSString *jsonStr = @&quot;{&quot;;
    NSArray * keys = [dictionary allKeys];
    for (NSString * key in keys) {
        jsonStr = [NSString stringWithFormat:@&quot;%@\&quot;%@\&quot;:\&quot;%@\&quot;,&quot;,jsonStr,key,[dictionary objectForKey:key]];
    }
    jsonStr = [NSString stringWithFormat:@&quot;%@%@&quot;,[jsonStr substringWithRange:NSMakeRange(0, jsonStr.length-1)],@&quot;}&quot;];
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>那么现在问题又来了，就是，NSDictionary allkeys或者allvalues取出来的数组是乱序的。 使用得到所有的key的数组后是一个无序的集合，如果我们需要正确的显示出它在此之前的顺序 ，可以通过检索来实现。</p><div class="language-objectivec line-numbers-mode" data-ext="objectivec"><pre class="language-objectivec"><code>NSArray <span class="token operator">*</span> keys <span class="token operator">=</span> <span class="token punctuation">[</span>dic allKeys<span class="token punctuation">]</span><span class="token punctuation">;</span>
    NSArray <span class="token operator">*</span>sortedKeys <span class="token operator">=</span> <span class="token punctuation">[</span>keys sortedArrayUsingSelector<span class="token punctuation">:</span><span class="token keyword">@selector</span><span class="token punctuation">(</span>caseInsensitiveCompare<span class="token punctuation">:</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>这样子我们就可以去做关于请求头的拼接</p><h3 id="xcode-控制台打印unicode字符串转换为中文" tabindex="-1"><a class="header-anchor" href="#xcode-控制台打印unicode字符串转换为中文" aria-hidden="true">#</a> Xcode 控制台打印Unicode字符串转换为中文</h3><p>Xcode 控制台打印Unicode字符串转换为中文</p><p>当通过接口获取到服务器的值时，最恶心的事情发生在控制台。</p><p>在Xcode的控制台里直接打印一个数组或者字典,输出的都是一些Unicode的编码,不方便调试. 要想看到中文,则要去获取对应的key或者数组下标.得到具体某一个对象才能看到中文,给我们调试起来很不方便.</p><p>而现在可以使用LYLUnicode输出中文, 使用也方便.代码也简洁,就几行代码. 直接把LYLUnicode拖到工程里就能让Xcode支持中文的输出了.</p><p>就这么简单的一行输出,不需要任何更改.,使用之前Xcode控制台是打印的Unicode编码, 把LYLUnicode拖进来之后,不做任何操作,输出的内容就是我们想看到的中文了.</p><p>Github是个好东西---------- githud地址：https://github.com/allencelee/LYLUnicode 我们通过上面的地址进入，下载下来，我们只取LYLUnicode文件夹就够了，里面就一个.h与.m文件。然后拖到工程中，重新运行就够了，什么都不需要做。</p><p>说实话具体原理还是没看懂，如果有兴趣可以去看看这个作者的理解，虽然感觉也没听懂他说的是个什么。 https://www.cnblogs.com/allencelee/p/9400281.html</p><h3 id="使用xcode出现警告、错误的解决方法总结" tabindex="-1"><a class="header-anchor" href="#使用xcode出现警告、错误的解决方法总结" aria-hidden="true">#</a> 使用Xcode出现警告、错误的解决方法总结</h3><p>使用Xcode出现警告、错误的解决方法总结</p><p>以下是网上总结的一些方法：</p><p>1，警告：“xoxoxoxo” is deprecated 解决办法：查看xoxoxoxo的这个方法的文档，替换掉这个方法即可。</p><p>2，警告：Declaration of &quot;struct sockaddr&quot; will not be visible outside of this function 解决办法：在你的开源.m文件中添加 #import</p><p>3，警告：Implicit conversion from enumeration type &#39;UIInterfaceOrientation&#39; to different enumeration type &#39;UIDeviceOrientation&#39; 解决办法：类型不匹配。跳到出错的那一行，UIInterfaceOrientation强制转换为UIDeviceOrientation就行了。</p><p>4，警告：incompatible pointer types assigning to &#39;MyArrayList*&#39;from &#39;NSMutableArray&#39; 解决办法：加入强制转换(MyArrayList*)</p><p>5，警告：&#39;&amp;&amp;&#39; within &#39;||&#39; 问题出处： if (exists &amp;&amp; !isDirectory || !exists)……… 解决办法： if ((exists &amp;&amp; !isDirectory) || !exists)………</p><p>6，警告：Warning：The Copy Bundle Resources build phase contains this target&#39;s Info.plist file 解决办法：将Info.plist文件移到Resources目录下，而不要直接放在target下。</p><p>7，警告：在使用ASIHttp…第三方库的，运行报错。 解决办法：看你的项目中是否添加CFNetwork.framework、SystemConfiguration.framework, MobileCoreServices.framework, CoreGraphics.framework和libz.1.2.3.dylib，如果是sdk5.0以上，改添加libz.1.2.5.dylib</p><p>8，警告：xxxooo，missing required architecture i386 in file 解决办法：如果是错误信息的话：Target-&gt;Build Settings-&gt;Search Paths, 删除FrameworkSearch Paths 里面内容就可以了。 要只是一个警告的话，真机调试可以过。具体解决方法待大神出现。</p><p>9，警告： clang: error: no such file or directory: &#39;/demo2/控件代码/13/Recorder/Recorder_Prefix.pch&#39; clang: error: no input files Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1 解决办法： 在你的主工程文件 target搜素，pch ，找到Prefix Header 把它后面的值，都删除，再运行就解决了。</p><p>10，警告： “ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute 解决办法：如果定义了ARC有效，那么必须要有所有者属性的定义;所以代码改成下面这样 @property (nonatomic, strong, readonly) NSString *ss;</p><p>11，警告： io6一下的xib系统均没有自动选择Use Autolayout， Supporting iOS 5 and below with xib of iOS 6 解决办法：Just un-select “Use Autolayout” in the file inspector of the xib’s view and we are back to the familiar autosizing in size inspector and boom, it supports iOS 5 and below.</p><p>12，警告： Warning: Multiple build commands for output file xxx.png 解决办法：找到项目里xxx.png重复，删除重复的资源。</p><p>//以下是升级到 xcode 5.0.1 之后使用遇到的警告 13，警告： “iOS 模拟器”未能安装此应用程序。 解决办法：删除模拟器上当前要运行那个APP，重新运行项目。就ok</p><p>14，警告： SpringBoard无法启动应用程序 错误:-3 解决办法：退出模拟器，重新运行这个项目。</p><p>15，警告： The server certificate failed to verify. 解决办法： 1、打开终端（实用工具 --&gt;终端），在终端中输入如下命令： svn ls https://192.100.1.11?0/svn/xxxxxx（注意下面的url更换成你自己的url地址） 然后直接输入 “ p ” 确认，就可以重新连接了。</p><p>16，警告： Bitmasking for introspection of Objective-C object pointers is strongly discouraged. 解决办法： 某数字&amp; 0x1的时候是代表要取最低位是否为1，改成了 if(JK_EXPECT_F(((NSUInteger)object)%2))即可。</p><p>17，警告： Implicit conversion loses integer precision: &#39;unsigned long&#39; to &#39;CC_LONG&#39; (aka &#39;unsigned int&#39;). 解决办法： CC_MD5(str,strlen(str), r);，改成了 CC_MD5(str, (CC_LONG)strlen(str), r);即可。</p><p>18，警告： error: failed to launch &#39;/private/var/mobile/Applications/xxxxx&#39; -- failed to get the task for process 11140. 解决办法： 重启你的开发手机即可，还有一种可能是你的开发者证书与发布证书搞错了，检查在xcode中证书是否一直 。</p><p>遇到相关的警告，一般编译器都会提供解决方案，所以，作为新手，我们应该看懂编译器给我们的提示，这样我们解决问题就会事半功倍。</p><p>1， 错误信息： &quot;OBJC_CLASS$ xxxxx &quot;, referenced from: objc-class-ref in ViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 解决方法： 查看工程，看是不是没有导入相关的框架。或者工程里添加的有相同&quot;.m&quot;,&quot;.h&quot; 文件</p><p>2， 错误信息： Couldn&#39;t register dy.CKRiLiText with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Current language: auto; currently objective-c 解决方法： 可能是电脑内存问题引起，重启电脑即可解决。如果重启解决不了问题，那就是你刚刚改动的代码引起的问题。</p><p>3 、 错误信息： ios 5是调试正常的，ios 6真机调试的时候,出现如下错误：ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/mac4/Desktop/my desktop/My app/MyApp name 20:09:12 /MyApp name/ZBarSDK/libzbar.a for architecture armv7serror: linker command failed with exit code 1 (use -v to see invocation) 解决方法：在Xcode里，点击相应的Target，然后点Build Settings，找到VALID_ARCHS，看里面的是不是arvm7s，如果不是改成arvm7s就可以了。</p><p>4 、 错误信息： error: receiver type &#39;ViewController&#39; for instance message does not declare a method with selector &#39;hideSearchBar:&#39; [4] ViewController 中没有声明一个方法选择&#39;hideSearchBar： 解决方法： 在ViewController .h 中声明一下这个方法 “ hideSearchBar ” 即可。</p><p>5、 错误信息：当json从服务端请求时得到的字符串，如果这样写的话，会报错，&#39;;&#39; after top level declarator NSString *ss= @&quot;{&quot;recommend&quot;:&quot;世界末日&quot;,&quot;dogname&quot;:&quot;机器人&quot;}&quot;; 解决方法： 就是，把 “ 替换成 &quot; 即可。NSString *ss= @&quot;{ &quot;recommend &quot;: &quot;世界末日 &quot;, &quot;dogname &quot;: &quot;机器人 &quot;}&quot;;</p><p>6 、 错误信息： error: Existing instance variable &#39;_datasource&#39; for property &#39;datasource&#39; with assign attribute must be __unsafe_unretained</p><p>解决方法： id _datasource; 改为 __unsafe_unretained id _datasource:即可</p><p>31，警告： warning: Semantic Issue: Incompatible integer to pointer conversion assigning to &#39;BOOL *&#39; (aka &#39;signed char *&#39;) from &#39;BOOL&#39; (aka &#39;signed char&#39;)</p><p>解决办法： 检查 BOOL ＊换为BOOL就可以了，检查是不是多写一个 ＊ 号。</p><p>32:Jsonkit中的警告</p><p>Direct access to objective-c&#39;s isa is deprecated in favor of object_setClass() and object_getClass() object-&gt;isa 替换为 object_getClass(object) keyObject-&gt;isa 替换为 object_getClass(keyObject) (id)keys[idx]-&gt;isa 替换为 object_getClass((id)keys[idx])</p><p>format specifies type &#39;unsigned long&#39; but the argument has type &#39;nsuinteger&#39; (aka &#39;unsigned int&#39;) 给变量增加(unsigned long)进行类型转换</p><p>33：md5加密（iOS SDK中自带了CommonCrypto</p><p>Implicit declaration of function &#39;CC_MD5&#39; is invalid in C99</p><p>[plain] view plaincopy</p><p>#define CC_MD5_DIGEST_LENGTH 16 +(NSString *)MD5HashForString:(NSString *)input { const char *cStr = [input UTF8String]; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(cStr, strlen(cStr), result); return [NSString stringWithFormat: @&quot;xxxxxxxxxxxxxxxx&quot;, result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]]; }</p><p>引入函数定义的头文件</p><p>#import</p><p>34:ASIDataDecompressor中的警告</p><p>format specifies type &#39;short&#39; but the argument has type &#39;int&#39;</p><p>在+ (NSError *)deflateErrorWithCode:(int)code 和 +(NSError *)inflateErrorWithCode:(int)code中</p><p>［NSString stringWithFormat:@&quot;Compression of data failed with code %hi&quot;,code] 中</p><p>将code改为 (short)code,类型转换</p><p>35：Reachability中警告</p><p>Using &#39;stringWithString:&#39; with a literal is redundant</p><p>statusString = [NSString stringWithString: @&quot;Not Reachable&quot;];</p><p>改为：statusString = @&quot;Not Reachable&quot;;</p><p>36.format specifies type &#39;id&#39; but the argument has type &#39;const char *&#39;</p><p>NSCAssert(NO, @&quot;Unhandled error encountered during SAX parse. msg is %@&quot;, msg); 改为：NSCAssert(NO, @&quot;Unhandled error encountered during SAX parse. msg is %@&quot;, [NSString stringWithUTF8String:msg]);</p><p>37 Using &#39;stringWithString:&#39; with a literal is redundant 改为：self.locationInput.text = @&quot;captured change&quot;;</p><p>38 在项目中设置控件的layer属性时，会发生错误, &quot;Property &#39;c&#39; cannot be found in forward class object &#39;CALayer *&quot;,</p><p>这时需要引入 #import 。</p><p>41,错误</p><p>Error launching remote program: failed to get the task for process</p><p>解决方法： 把真机上的软件，删除，然后，clean 一下，重新运行就可以了。</p><p>42,真机调试的时候，出现 [attachment=49364] 这正常，但是不识别机器的。</p><p>解决方法：</p><p>把 ， [attachment=49365] 设置为以上相对应的版本就可以了。</p><p>43,真机调试的时候，出现 ios Broken pipe</p><p>解决方法： :推出xcode :断开机器(iphone,ipad,ipod)链接 :重启iPhone在联接xcode，就可以了。</p><p>iOS真机调试中出现identity(The identity &#39;iPhone Developer)证书不匹配的问题</p><p>提示(null) error: could not read CFBundleIdentifier from Info.plist (null)</p><p>新建一个同名工程，拷贝其plist文件，将原工程中的plist文件替换掉即可。</p></div></div><footer class="page-meta"><div class="meta-item edit-link"><span class="xicon-container left meta-item-label"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M2 26h28v2H2z" fill="currentColor"></path><path d="M25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4l15-15zm-5-5L24 7.6l-3 3L17.4 7l3-3zM6 22v-3.6l10-10l3.6 3.6l-10 10H6z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Edit this page<!--]--></span></span></div><div class="meta-item last-updated"><span class="xicon-container left meta-item-label"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Last Updated 2023-04-08 09:19:01<!--]--></span></span></div></footer><!----><!----></main><!--]--><div class="page-catalog-container"><h5 class="tip">文章目录</h5><ul><!--[--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/wb/blogs/houduan/092106.html#视图控制器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="视图控制器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->视图控制器<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#基本用法" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="基本用法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->基本用法<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#类的声明" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="类的声明"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->类的声明<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/wb/blogs/houduan/092106.html#常用控件" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="常用控件"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->常用控件<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#button控件" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Button控件"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Button控件<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#图片按钮" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="图片按钮"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->图片按钮<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/wb/blogs/houduan/092106.html#开发问题" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="开发问题"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->开发问题<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#解决uitableview中cell重用" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="解决UITableView中Cell重用"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->解决UITableView中Cell重用<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#afnetworking-v3-0-封装和使用" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="AFNetworking V3.0+ 封装和使用"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->AFNetworking V3.0+ 封装和使用<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#afnetworking3-0带参数请求体以及带请求头" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="AFNetworking3.0带参数请求体以及带请求头"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->AFNetworking3.0带参数请求体以及带请求头<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#xcode-控制台打印unicode字符串转换为中文" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Xcode 控制台打印Unicode字符串转换为中文"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Xcode 控制台打印Unicode字符串转换为中文<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/wb/blogs/houduan/092106.html#使用xcode出现警告、错误的解决方法总结" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="使用Xcode出现警告、错误的解决方法总结"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->使用Xcode出现警告、错误的解决方法总结<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--]--></ul></div></div></div></div><!----><!----><!--]--></div>
    <script type="module" src="/wb/assets/app-32a7af8e.js" defer></script>
  </body>
</html>
